<?php include('header.php'); ?>

<?php
include("/usr/local/apache2/htdocs/jibaiwang/lib/Feedback.php");
include("/usr/local/apache2/htdocs/jibaiwang/lib/Login.php");
include('log4php/Logger.php');
$cfgfile = "/usr/local/apache2/htdocs/jibaiwang/admin/conf/config.ini";
$defarray = parse_ini_file($cfgfile, 1);
$qlogtag = $defarray["Feedback"]['qlogtag'];
Logger::configure($defarray["Feedback"]['qlogcfg']);
$logger = Logger::getLogger($qlogtag);
$host = $defarray["Feedback"]["host"];
$user = $defarray["Feedback"]["user"];
$pass = $defarray["Feedback"]["pass"];
$db = $defarray["Feedback"]["db"];
$dbh = new Sqlexecutor($host, $user, $pass, $db);
$s = new Feedback($dbh,$logger);
$su = new Login($dbh,$logger);
$type_array = array("1"=>"投诉","2"=>"建议");
$status_array = array("1"=>"已回复","0"=>"未回复");
$list = $s->getList();
if($_REQUEST["op"] == "del")
{
    $res = $s->deleteByID($_REQUEST["rule_id"]);
    header("Location:Feedback.php");
}
if($_REQUEST["feedback"] == "on")
{
    $res = $s->replyByID($_REQUEST["rule_reply"],$_REQUEST["b_id"]);
    header("Location:Feedback.php");
    if($_REQUEST["feedback"] == "on")
    {
        $res = $s->replyByID($_REQUEST["rule_reply"],$_REQUEST["b_id"]);
        header("Location:Feedback.php");
    }
}
?>


            <div>
				<ul class="breadcrumb">
					<li>
						<a href="#">系统管理</a> <span class="divider">/</span>
					</li>
					<li>
						<a href="#">经销商反馈管理</a>
					</li>
				</ul>
			</div>
			<div class="row-fluid3 sortable">
				<div class="box span12">
					<div class="box-header well" data-original-title>
						<h2><i class="icon-font"></i>经销商反馈管理</h2>
<!--
						<div class="box-icon">
							<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
							<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
							<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
						</div>
-->
					</div>

                    <div class="box-content">

                    <table class="table table-striped bootstrap-datatable datatable">
                    <thead>
                    <tr>
                    <th>#</th>
              <th>反馈内容</th>
              <th>回复内容</th>
              <th>状态</th>
              <th>类型</th>
              <th>反馈人</th>
              <th>反馈时间</th>
              <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                <?php       
                foreach($list as $key => $value)
                {
                    $user_array = $su->getInfoByID($value["usrid"]);
                    echo '<form class="form-horizontal" target="_self">';
                    echo "<tr>";
                    echo '<td><input id="b_'.$value["id"].'" type="hidden" class="span1" name="b_id" readonly value="'.$value["id"].'">'.$value["id"].'</td>';
                    echo '<input type="hidden" class="span1" name="feedback" readonly value="on">';
                    echo '<td><textarea id="content_'.$value["id"].'" readonly name="content" class="autogrow" >'.$value["content"].'</textarea></td>';
                    echo '<td><textarea id="content_'.$value["id"].'" name="rule_reply" class="autogrow"  >'.$value["reply"].'</textarea></td>';
                    echo "<td>";
                    if($value["status"] == 0 ) echo '<span class="label label-warning" >'. $status_array[$value["status"]]."</span></td>";
                    if($value["status"] == 1 ) echo '<span class="label label-success" >'. $status_array[$value["status"]]."</span></td>";
                    echo "<td>".$type_array[$value["type"]]."</td>";
                    echo "<td>".$user_array["name"]."</td>";
                    echo "<td>".$value["insert_date"]."</td>";
                    echo "<td>";
                    echo '<button class="btn btn-primary" type="submit" value="回复">回复</button>';
                    echo '<a onclick="modify_del('.$value["id"].')" class="btn btn-warning" >删除</a>';
                    echo "</td>";
                    echo "</tr>";
                    echo "</form>";
                }
                ?>
                    </tbody>
                    </table>

                    </div>
				</div><!--/span-->
			
            </div><!--/row-->
                <script type="text/javascript">
                function modify_del(id){
                    if(window.confirm("确定删除吗？")){
                        str="?op=del&rule_id="+id
                            window.open(str,'_self');
                    }
                }

                function modify_on(id,reply){
                    if(window.confirm("确定回复吗？")){
                        str="?op=on&rule_id="+id+"&rule_reply="+reply
                            window.open(str,'_self');
                    }
                }
                </script> 
<?php include('footer.php'); ?>
